


capt prog drop appendmodels
*! version 1.0.0  April 26, 2023 @ 10:11:24
program appendmodels, eclass
    // using first equation of model
    version 8
    syntax namelist
    tempname b V tmp
    foreach name of local namelist {
        qui est restore `name'
        mat `tmp' = e(b)
        local eq1: coleq `tmp'
        gettoken eq1 : eq1
        mat `tmp' = `tmp'[1,"`eq1':"]
        local cons = colnumb(`tmp',"_cons")
        if `cons'<. & `cons'>1 {
            mat `tmp' = `tmp'[1,1..`cons'-1]
        }
        mat `b' = nullmat(`b') , `tmp'
        mat `tmp' = e(V)
        mat `tmp' = `tmp'["`eq1':","`eq1':"]
        if `cons'<. & `cons'>1 {
            mat `tmp' = `tmp'[1..`cons'-1,1..`cons'-1]
        }
        capt confirm matrix `V'
        if _rc {
            mat `V' = `tmp'
        }
        else {
            mat `V' = ///
            ( `V' , J(rowsof(`V'),colsof(`tmp'),0) ) \ ///
            ( J(rowsof(`tmp'),colsof(`V'),0) , `tmp' )
        }
    }
    local names: colfullnames `b'
    mat coln `V' = `names'
    mat rown `V' = `names'
    eret post `b' `V'
    eret local cmd "whatever"
end


local feet $feet
/** FIgure 1 **/
/** made with make_incremental_exhibhits.do **/

/** Figure 2 and 3 Elsewhere ***/

/** Figure 4 */
/* figures - coefficients from regression with interactions by year */
reghdfe mma_spread_mvw_w pct_std  ib2007.year#c.(pct_std ) $controls if eastcoast ==1 | gulfcoast ==1 , absorb(ym_date##fips $intcontrols dist_num) vce(cluster fips ym_date)
mat b =e(b)
mat b = b[1,2..18]
mat b = b'
mat V =e(V)
mat V = vecdiag(V)
mat V = V[1,2..18]'
preserve
clear
svmat b
svmat V
keep if b1 != .
gen year = 2000 + _n
gen ci_upper = b1 + 1.96*sqrt(V1)
gen ci_lower = b1 - 1.96*sqrt(V1)
twoway (rcap ci_upper ci_lower year) (connected b1 year, mcolor(black) lcolor(black)), yline(0, lcolor(black))  xlabel(2002(3)2017) xtitle("") legend(off) 
graph export "$graphPath/regression_eastgulf_balanced.png", replace
graph export "$graphPath/regression_eastgulf_balanced.pdf", replace
restore

/** Figure 5-6 **/
/** Matlab code **/ 

/*** Appendix Figure X **/
eststo: reghdfe log_median_hp pct_std ib2007.year#c.pct_std  $controls if  state != "CA" &log_median_hp !=., absorb(ym_date##fips dist_num  $intcontrols) vce(cluster fips ym_date)
mat b =e(b)
mat b = b[1,2..18]
mat b = b'
mat V =e(V)
mat V = vecdiag(V)
mat V = V[1,2..18]'
preserve
clear
svmat b
svmat V
keep if b1 != .
gen year = 2000 + _n
gen ci_upper = b1 + 1.96*sqrt(V1)
gen ci_lower = b1 - 1.96*sqrt(V1)
twoway (rcap ci_upper ci_lower year) (connected b1 year, mcolor(black) lcolor(black)), yline(0, lcolor(black))  xlabel(2002(3)2017) xtitle("") legend(off) 
graph export "$graphPath/hp_graph.png", replace
graph export "$graphPath/hp_graph.pdf", replace
restore



/* Table 1: Summary Stats */
local summary_vars  percent_exposed_`feet' stormsurge yield_mvw_w mma_bench mma_spread_mvw_w time_to_mat bond_age monthly_volume liq_turnover_w price_month_stdev callable_dum insured_dum genob_dum irs_avg_income rate_p local_pct ave_state_worried_2014_nonorm
label var rate_p "Property Tax Rate"
label var stormsurge "Storm Surge Exposure"
label var callable_dum "1(Callable)"
label var insured_dum "1(Insured)"
label var genob_dum "1(General Obligation)"
label var local_pct "School Local Funding"

replace average_value=average_value/1000
preserve
keep if state != "CA"
eststo clear
estpost sum `summary_vars'
est store a
estpost sum `summary_vars' if percent_exposed_`feet' > 0
est store b
esttab a b using "$tablePath/summary_stats_balanced_noca.tex", booktabs replace compress nogaps b(3) /// ///
mtitles("\textbf{\emph{Full Coastal Sample}}" "\textbf{\emph{SLR Exposed Districts}}") ///
collabels(\multicolumn{1}{c}{{Mean}} \multicolumn{1}{c}{{Std.Dev.}} \multicolumn{1}{l}{{Obs.}}) ///
cells("mean(fmt(2)) sd(fmt(2)) count(fmt(%9.0fc))") label noobs
restore

preserve
keep if state == "CA"
eststo clear
estpost sum `summary_vars'
est store a
estpost sum `summary_vars' if percent_exposed_`feet' > 0
est store b
esttab a b using "$tablePath/summary_stats_balanced_ca.tex", booktabs replace compress nogaps b(3) /// ///
mtitles("\textbf{\emph{Full Coastal Sample}}" "\textbf{\emph{SLR Exposed Districts}}") ///
collabels(\multicolumn{1}{c}{{Mean}} \multicolumn{1}{c}{{Std.Dev.}} \multicolumn{1}{l}{{Obs.}}) ///
cells("mean(fmt(2)) sd(fmt(2)) count(fmt(%9.0fc))") label noobs
restore

eststo clear
estpost sum `summary_vars' 
est store a
estpost sum `summary_vars' if percent_exposed_`feet' > 0
est store b
esttab a b using "$tablePath/summary_stats_balanced.tex", booktabs replace compress nogaps b(3) /// ///
mtitles("\textbf{\emph{Full Coastal Sample}}" "\textbf{\emph{SLR Exposed Districts}}") ///
collabels(\multicolumn{1}{c}{{Mean}} \multicolumn{1}{c}{{Std.Dev.}} \multicolumn{1}{l}{{Obs.}}) ///
cells("mean(fmt(2)) sd(fmt(2)) count(fmt(%9.0fc))") label noobs


/*** Table 2 ***/

forvalues i = 2001(1)2017 {
	if `i' != 2007 {
		capture drop pct_std_`i'
		gen pct_std_`i' = pct_std*(year == `i')
		label var pct_std_`i' "SLR Exposure \$\times\$ 1(Year `i')"		
		}
	}

quietly{
est clear

eststo: reghdfe mma_spread_mvw_w pct_std pct_std_* if state != "CA", absorb(ym_date##fips) vce(cluster fips ym_date)
	estadd scalar N_true = e(N) + e(num_singletons)
		estadd scalar within_r2 = e(r2_within)	
sum mma_spread_mvw_w if e(sample) == 1
estadd scalar outcome_mean r(mean)
estadd scalar outcome_sd r(sd)
estadd local has_controls "N"
estadd local has_issuer_fe "N"
estadd local has_county_ym_fe "Y"

eststo: reghdfe mma_spread_mvw_w  pct_std_* if state != "CA", absorb(ym_date##fips dist_num) vce(cluster fips ym_date)
	estadd scalar N_true = e(N) + e(num_singletons)
			estadd scalar within_r2 = e(r2_within)
sum mma_spread_mvw_w if e(sample) == 1
estadd scalar outcome_mean r(mean)
estadd scalar outcome_sd r(sd)
estadd local has_controls "N"
estadd local has_issuer_fe "Y"
estadd local has_county_ym_fe "Y"

eststo: reghdfe mma_spread_mvw_w i.year  pct_std_*  $controls if state != "CA", absorb(ym_date##fips $intcontrols dist_num) vce(cluster fips ym_date)
	estadd scalar N_true = e(N) + e(num_singletons)
			estadd scalar within_r2 = e(r2_within)
sum mma_spread_mvw_w if e(sample) == 1
estadd scalar outcome_mean r(mean)
estadd scalar outcome_sd r(sd)
estadd local has_controls "Y"
estadd local has_issuer_fe "Y"
estadd local has_county_ym_fe "Y"

}


esttab, compress nogaps b(3) keep(pct_std pct_std_* )   ///
 stats(has_controls  has_county_ym_fe has_issuer_fe outcome_mean outcome_sd N_true r2 within_r2, fmt(%9.3fc %9.3fc %9.3fc %9.3fc %9.3fc  %9.0fc %9.4f %9.4f) ///
  labels(  "Controls" "County-Year-Month FE" "District FE"  "Outcome Mean" "Outcome SD" "Observations" "R\$^2\$" "Within-R\$^2\$")) ///
  label interaction(" X ") starlevels(* 0.10 ** 0.05 *** 0.01) nomtitles  
esttab using ${tablePath}/regressions_main_${isbal}_6_std.tex, booktabs replace compress nogaps b(3) keep(pct_std pct_std_* )  ///
 stats(has_controls  has_county_ym_fe has_issuer_fe outcome_mean outcome_sd N_true r2 within_r2, fmt(%9.3fc %9.3fc %9.3fc %9.3fc %9.3fc  %9.0fc %9.4f %9.4f) ///
 labels(  "Controls" "County-Year-Month FE" "District FE"  "Outcome Mean" "Outcome SD" "Observations" "R\$^2\$" "Within-R\$^2\$")) /// 
 label interaction(" $\times$ ") starlevels(* 0.10 ** 0.05 *** 0.01) nomtitles  nonotes



/** Table 2 Panel B **/
gen pct_std_post = pct_std*post
label var pct_std_post "SLR Exposure \$\times\$ 1(Post)"

quietly{
est clear

eststo: reghdfe mma_spread_mvw_w pct_std pct_std_post if state != "CA", absorb(ym_date##fips) vce(cluster fips ym_date)
	estadd scalar N_true = e(N) + e(num_singletons)
		estadd scalar within_r2 = e(r2_within)	
sum mma_spread_mvw_w if e(sample) == 1
estadd scalar outcome_mean r(mean)
estadd scalar outcome_sd r(sd)
estadd local has_controls "N"
estadd local has_issuer_fe "N"
estadd local has_county_ym_fe "Y"

eststo: reghdfe mma_spread_mvw_w pct_std_post if state != "CA", absorb(ym_date##fips dist_num) vce(cluster fips ym_date)
	estadd scalar N_true = e(N) + e(num_singletons)
			estadd scalar within_r2 = e(r2_within)
sum mma_spread_mvw_w if e(sample) == 1
estadd scalar outcome_mean r(mean)
estadd scalar outcome_sd r(sd)
estadd local has_controls "N"
estadd local has_issuer_fe "Y"
estadd local has_county_ym_fe "Y"

eststo: reghdfe mma_spread_mvw_w pct_std_post  $controls if state != "CA", absorb(ym_date##fips $intcontrols dist_num) vce(cluster fips ym_date)
	estadd scalar N_true = e(N) + e(num_singletons)
			estadd scalar within_r2 = e(r2_within)
sum mma_spread_mvw_w if e(sample) == 1
estadd scalar outcome_mean r(mean)
estadd scalar outcome_sd r(sd)
estadd local has_controls "Y"
estadd local has_issuer_fe "Y"
estadd local has_county_ym_fe "Y"

}


esttab, compress nogaps b(3) keep(pct_std pct_std_post )   ///
 stats(has_controls  has_county_ym_fe has_issuer_fe outcome_mean outcome_sd N_true r2 within_r2, fmt(%9.3fc %9.3fc %9.3fc %9.3fc %9.3fc  %9.0fc %9.4f %9.4f) ///
  labels(  "Controls" "County-Year-Month FE" "District FE"  "Outcome Mean" "Outcome SD" "Observations" "R\$^2\$" "Within-R\$^2\$")) ///
  label interaction(" X ") starlevels(* 0.10 ** 0.05 *** 0.01) nomtitles  
esttab using ${tablePath}/regressions_main_${isbal}_6_std_panelb.tex, booktabs replace compress nogaps b(3) keep(pct_std pct_std_* )  ///
 stats(has_controls  has_county_ym_fe has_issuer_fe outcome_mean outcome_sd N_true r2 within_r2, fmt(%9.3fc %9.3fc %9.3fc %9.3fc %9.3fc  %9.0fc %9.4f %9.4f) ///
 labels(  "Controls" "County-Year-Month FE" "District FE"  "Outcome Mean" "Outcome SD" "Observations" "R\$^2\$" "Within-R\$^2\$")) /// 
 label interaction(" $\times$ ") starlevels(* 0.10 ** 0.05 *** 0.01) nomtitles  nonotes


/*** Table 3 ***/
/*stormsurge and maturity interaction */

label var log_maturity "Log(Maturity)"
gen pct_std_maturity = pct_std*log_maturity
label var pct_std_maturity "SLR Exposure \$\times\$ 1(Post)"
gen pct_std_post_maturity = pct_std*log_maturity*post
label var pct_std_post_maturity "SLR Exposure \$\times\$ 1(Post) \$\times\$ Log(Maturity)"

capture drop stormsurge_post
gen stormsurge_post = stormsurge_std_w * post
label var stormsurge_post "Storm Surge Exposure \$\times\$ 1(Post)"
center log_maturity, standardize
replace pct_std_post_maturity=c_log_maturity*pct_std_post
g stormsurge_post_maturity=c_log_maturity*stormsurge_post
label var stormsurge_post_maturity "Storm Surge Exposure $\times$ 1(Post) $\times$ Log(Maturity) "



est clear



eststo: reghdfe mma_spread_mvw_w  pct_std_post   $controls if  state != "CA", absorb(ym_date##fips dist_num $intcontrols)  vce(cluster fips ym_date)

estadd scalar N_true = e(N) + e(num_singletons)
sum mma_spread_mvw_w if e(sample) == 1
estadd scalar outcome_mean r(mean)
estadd scalar outcome_sd r(sd)
estadd local subsample "East \& Gulf"
estadd local mat_range "All"
estadd local has_controls "Y"
estadd local has_county_ym_fe "Y"
estadd local has_issuer_fe "Y"
estadd local has_dist_ym_fe "N"
estadd local equal_weight "N"




eststo: reghdfe mma_spread_mvw_w  pct_std_post  stormsurge_post $controls if  state != "CA", absorb(ym_date##fips dist_num $intcontrols) vce(cluster fips ym_date)

estadd scalar N_true = e(N) + e(num_singletons)
sum mma_spread_mvw_w if e(sample) == 1
estadd scalar outcome_mean r(mean)
estadd scalar outcome_sd r(sd)
estadd local subsample "East \& Gulf"
estadd local mat_range "All"
estadd local has_controls "Y"
estadd local has_county_ym_fe "Y"
estadd local has_issuer_fe "Y"
estadd local has_dist_ym_fe "N"
estadd local equal_weight "N"


eststo: reghdfe mma_spread_mvw_w  c.pct_std#c.c_log_maturity pct_std_post_maturity    $controls if  state != "CA", absorb(ym_date##dist_num $intcontrols) vce(cluster fips ym_date)

estadd scalar N_true = e(N) + e(num_singletons)
sum mma_spread_mvw_w if e(sample) == 1
estadd scalar outcome_mean r(mean)
estadd scalar outcome_sd r(sd)
estadd local subsample "East \& Gulf"
estadd local mat_range "All"
estadd local has_controls "Y"
estadd local has_county_ym_fe "Y"
estadd local has_issuer_fe "N"
estadd local has_dist_ym_fe "Y"
estadd local equal_weight "N"



esttab, compress nogaps b(3) keep(pct_std_post stormsurge_post pct_std_post_maturity ) ///
 stats( mat_range has_controls has_issuer_fe has_county_ym_fe has_dist_ym_fe outcome_mean outcome_sd N_true, fmt( %9.3fc %9.3fc %9.3fc %9.3fc %9.3fc %9.3fc %9.3fc %9.0fc) ///
 labels("Maturity Range" "Controls" "District FE" "County-Year-Month FE" "District-Year-Month FE" "Outcome Mean" "Outcome SD" "Observations")) ///
 label interaction(" X ") varwidth(60) starlevels(* 0.10 ** 0.05 *** 0.01) nomtitles 

 
 esttab using "$tablePath/regs_stormsurge_${isbal}_`feet'.tex", booktabs replace  compress nogaps b(3) keep(pct_std_post stormsurge_post pct_std_post_maturity ) ///
 stats( mat_range has_controls has_issuer_fe has_county_ym_fe has_dist_ym_fe outcome_mean outcome_sd N_true, fmt( %9.3fc %9.3fc %9.3fc %9.3fc %9.3fc %9.3fc %9.3fc %9.0fc) ///
 labels("Maturity Range" "Controls" "District FE" "County-Year-Month FE" "District-Year-Month FE" "Outcome Mean" "Outcome SD" "Observations")) ///
 label interaction(" X ") varwidth(60) starlevels(* 0.10 ** 0.05 *** 0.01) nomtitles 


 

/*** Table 4 ***/
/*** House Price as Outcome ***/

gen log_med_pr_weighted_exp2 = log(pctexposed* exp(log_med_pr_exp_yr) + (1-pctexposed)*exp(log_med_pr_noexp_yr))
est clear
foreach x of varlist  log_median_hp  log_med_pr_exp_yr log_med_pr_noexp_yr  log_med_pr_weighted_exp2 log_zillow_hp {
quietly{ 
	eststo: reghdfe `x'  pct_std_post $controls if  state != "CA", absorb(ym_date##fips dist_num  $intcontrols) vce(cluster fips ym_date)
	estadd scalar N_true = e(N) + e(num_singletons)
		estadd scalar within_r2 = e(r2_within)
	sum `x' if e(sample) == 1
estadd scalar outcome_mean r(mean)
estadd scalar outcome_sd r(sd)
estadd local subsample "East \& Gulf"
estadd local worried "All"
estadd local has_controls "Y"
estadd local has_issuer_fe "Y"
estadd local has_county_ym_fe "Y"
estadd local equal_weight "N"
		}
	}
esttab, compress nogaps b(3) keep( pct_std_post) ///
stats(   has_controls has_county_ym_fe has_county_ym_fe  outcome_mean outcome_sd N_true r2 within_r2, fmt( %9.3fc %9.3fc %9.3fc %9.3fc %9.3fc %9.0fc %9.4f) ///
 labels(  "Controls" "District FE" "County-Year-Month FE" "Outcome Mean" "Outcome SD" "Observations" "R\$^2\$" "Within-R\$^2\$")) ///
  label interaction(" X ") starlevels(* 0.10 ** 0.05 *** 0.01) nomtitles 
esttab using "$tablePath/regs_outcome_house_price_table.tex", booktabs replace compress nogaps b(3) keep(pct_std_post) ///
stats( hp_measure  has_controls has_county_ym_fe has_county_ym_fe   outcome_mean outcome_sd N_true r2 within_r2, fmt( %9.3fc %9.3fc %9.3fc %9.3fc %9.3fc %9.3fc %9.0fc %9.4f %9.4f) ///
 labels( "House Price Control Measure" "Controls" "District FE" "County-Year-Month FE" "Outcome Mean" "Outcome SD" "Observations" "R\$^2\$" "Within-R\$^2\$")) ///
  label interaction(" $\times$ ") starlevels(* 0.10 ** 0.05 *** 0.01) nomtitles  nonotes

estimates clear
foreach x of varlist  log_median_hp  log_med_pr_exp_yr log_med_pr_noexp_yr  log_med_pr_weighted_exp2 log_zillow_hp {
quietly{ 
	eststo: reghdfe `x'  pct_std_post $controls if  state != "CA" & year > 2006, absorb(ym_date##fips dist_num  $intcontrols) vce(cluster fips ym_date)
	estadd scalar N_true = e(N) + e(num_singletons)
		estadd scalar within_r2 = e(r2_within)
	sum `x' if e(sample) == 1
estadd scalar outcome_mean r(mean)
estadd scalar outcome_sd r(sd)
estadd local subsample "East \& Gulf"
estadd local worried "All"
estadd local has_controls "Y"
estadd local has_issuer_fe "Y"
estadd local has_county_ym_fe "Y"
estadd local equal_weight "N"
		}
	}
esttab, compress nogaps b(3) keep( pct_std_post) ///
stats(   has_controls has_county_ym_fe has_county_ym_fe  outcome_mean outcome_sd N_true r2 within_r2, fmt( %9.3fc %9.3fc %9.3fc %9.3fc %9.3fc %9.0fc %9.4f) ///
 labels(  "Controls" "District FE" "County-Year-Month FE" "Outcome Mean" "Outcome SD" "Observations" "R\$^2\$" "Within-R\$^2\$")) ///
  label interaction(" X ") starlevels(* 0.10 ** 0.05 *** 0.01) nomtitles 
esttab using "$tablePath/regs_outcome_house_price_table_2007.tex", booktabs replace compress nogaps b(3) keep(pct_std_post) ///
stats( hp_measure  has_controls has_county_ym_fe has_county_ym_fe   outcome_mean outcome_sd N_true r2 within_r2, fmt( %9.3fc %9.3fc %9.3fc %9.3fc %9.3fc %9.3fc %9.0fc %9.4f %9.4f) ///
 labels( "House Price Control Measure" "Controls" "District FE" "County-Year-Month FE" "Outcome Mean" "Outcome SD" "Observations" "R\$^2\$" "Within-R\$^2\$")) ///
  label interaction(" $\times$ ") starlevels(* 0.10 ** 0.05 *** 0.01) nomtitles  nonotes


/*** Table 5 ***/
/**  Controlling for House Prices in Main Specification**/
label var log_median_hp "Log(Median House Price)"
label var log_med_pr_noexp_yr "Log(MHP Not Exposed)"
label var log_med_pr_exp_yr "Log(MHP Exposed)"
label var reg_price_index "Hedonic Price Index"
gen log_median_hp_post = log_median_hp*post
gen log_zillow_hp_post = log_zillow_hp*post
foreach x in  log_p10_price log_p25_price log_p75_price log_p90_price log_med_pr_exp_yr log_med_pr_noexp_yr {
	gen `x'_post = `x'*post
}


label var log_median_hp_post "Log(Median House Price) x Post"
label var log_zillow_hp_post "Log(Median Zillow House Price) x Post"
label var log_med_pr_noexp_yr "Log(MHP Not Exposed) x Post"
label var log_med_pr_exp_yr "Log(MHP Exposed) x Post"
label var log_p10_price_post "Log(HP 10th Percentile) x Post"
label var log_p25_price_post "Log(HP 25th Percentile) x Post"
label var log_p75_price_post "Log(HP 75th Percentile) x Post"
label var log_p90_price_post "Log(HP 90th Percentile) x Post"


/*** with Year interaction for Editor **/
estimates clear
quietly {
	eststo: reghdfe mma_spread_mvw_w pct_std_post $controls if  state != "CA" &log_median_hp !=., absorb(ym_date##fips dist_num  $intcontrols) vce(cluster fips ym_date)
	estadd scalar N_true = e(N) + e(num_singletons)
		estadd scalar within_r2 = e(r2_within)
	sum mma_spread_mvw_w if e(sample) == 1
estadd scalar outcome_mean r(mean)
estadd scalar outcome_sd r(sd)
	estadd local subsample "East \& Gulf"
	estadd local hp_measure "None"	
estadd local worried "All"
estadd local has_controls "Y"
estadd local has_issuer_fe "Y"
estadd local has_county_ym_fe "Y"
estadd local equal_weight "N"

	eststo: reghdfe mma_spread_mvw_w pct_std_post c.log_median_hp#i.year  $controls if  state != "CA" &log_median_hp !=., absorb(ym_date##fips dist_num  $intcontrols) vce(cluster fips ym_date)
	estadd scalar N_true = e(N) + e(num_singletons)
	estadd scalar within_r2 = e(r2_within)
sum mma_spread_mvw_w if e(sample) == 1
estadd scalar outcome_mean r(mean)
estadd scalar outcome_sd r(sd)
	estadd local subsample "East \& Gulf"
	estadd local hp_measure "Median HP"	
estadd local worried "All"
estadd local has_controls "Y"
estadd local has_issuer_fe "Y"
estadd local has_county_ym_fe "Y"
estadd local equal_weight "N"

eststo: reghdfe mma_spread_mvw_w pct_std_post c.(log_med_pr_exp_yr log_med_pr_noexp_yr)#i.year $controls if  state != "CA"  &log_median_hp !=., absorb(ym_date##fips dist_num  $intcontrols) vce(cluster fips ym_date)
	estadd scalar N_true = e(N) + e(num_singletons)
			estadd scalar within_r2 = e(r2_within)
sum mma_spread_mvw_w if e(sample) == 1
estadd scalar outcome_mean r(mean)
estadd scalar outcome_sd r(sd)
estadd local subsample "East \& Gulf"
	estadd local hp_measure "MHP by Exposure"
	estadd local worried "All"
estadd local has_controls "Y"
estadd local has_issuer_fe "Y"
estadd local has_county_ym_fe "Y"
estadd local equal_weight "N"

eststo: reghdfe mma_spread_mvw_w pct_std_post  c.(log_zillow_hp)#i.year $controls if  state != "CA" &log_median_hp !=., absorb(ym_date##fips dist_num  $intcontrols) vce(cluster fips ym_date)
	estadd scalar N_true = e(N) + e(num_singletons)
			estadd scalar within_r2 = e(r2_within)
sum mma_spread_mvw_w if e(sample) == 1
estadd scalar outcome_mean r(mean)
estadd scalar outcome_sd r(sd)
estadd local subsample "East \& Gulf"
	estadd local hp_measure "Zillow HP"
	estadd local worried "All"
estadd local has_controls "Y"
estadd local has_issuer_fe "Y"
estadd local has_county_ym_fe "Y"
estadd local equal_weight "N"


eststo: reghdfe mma_spread_mvw_w pct_std_post c.(log_median_hp  log_p10_price log_p25_price log_p75_price log_p90_price)#i.year    $controls if  state != "CA" &log_median_hp !=., absorb(ym_date##fips dist_num  $intcontrols) vce(cluster fips ym_date)
	estadd scalar N_true = e(N) + e(num_singletons)
			estadd scalar within_r2 = e(r2_within)
sum mma_spread_mvw_w if e(sample) == 1
estadd scalar outcome_mean r(mean)
estadd scalar outcome_sd r(sd)
estadd local subsample "East \& Gulf"
	estadd local hp_measure "HP Dist."
	estadd local worried "All"
estadd local has_controls "Y"
estadd local has_issuer_fe "Y"
estadd local has_county_ym_fe "Y"
estadd local equal_weight "N"
}
esttab, compress nogaps b(3) keep( pct_std_post ) ///
stats(   has_controls has_county_ym_fe has_county_ym_fe  outcome_mean outcome_sd N_true r2 within_r2, fmt( %9.3fc %9.3fc %9.3fc %9.3fc %9.3fc %9.0fc %9.4f) ///
 labels(  "Controls" "District FE" "County-Year-Month FE" "Outcome Mean" "Outcome SD" "Observations" "R\$^2\$" "Within-R\$^2\$")) ///
  label interaction(" X ") starlevels(* 0.10 ** 0.05 *** 0.01) nomtitles 
esttab using "$tablePath/regs_house_price_table_w_year.tex", booktabs replace compress nogaps b(3) keep(pct_std_post) ///
stats( hp_measure  has_controls has_county_ym_fe has_county_ym_fe   outcome_mean outcome_sd N_true r2 within_r2, fmt( %9.3fc %9.3fc %9.3fc %9.3fc  %9.3fc %9.3fc %9.0fc %9.4f %9.4f) ///
 labels("House Price Control Measure" "Controls" "District FE" "County-Year-Month FE"   "Outcome Mean" "Outcome SD" "Observations" "R\$^2\$" "Within-R\$^2\$")) ///
  label interaction(" $\times$ ") starlevels(* 0.10 ** 0.05 *** 0.01) nomtitles  nonotes

estimates clear
quietly {
	eststo: reghdfe mma_spread_mvw_w  pct_std_post $controls if  state != "CA" &log_median_hp !=. & year > 2006, absorb(ym_date##fips dist_num  $intcontrols) vce(cluster fips ym_date)
	estadd scalar N_true = e(N) + e(num_singletons)
		estadd scalar within_r2 = e(r2_within)
	sum mma_spread_mvw_w if e(sample) == 1
	estadd scalar outcome_mean r(mean)
	estadd scalar outcome_sd r(sd)
	estadd local subsample "East \& Gulf"
	estadd local hp_measure "None"	
	estadd local worried "All"
	estadd local has_controls "Y"
	estadd local has_issuer_fe "Y"
	estadd local has_county_ym_fe "Y"
	estadd local equal_weight "N"

	eststo: reghdfe mma_spread_mvw_w pct_std_post c.log_median_hp#i.year  $controls if  state != "CA" &log_median_hp !=. & year > 2006, absorb(ym_date##fips dist_num  $intcontrols) vce(cluster fips ym_date)
	estadd scalar N_true = e(N) + e(num_singletons)
	estadd scalar within_r2 = e(r2_within)
sum mma_spread_mvw_w if e(sample) == 1
estadd scalar outcome_mean r(mean)
estadd scalar outcome_sd r(sd)
	estadd local subsample "East \& Gulf"
	estadd local hp_measure "Median HP"	
estadd local worried "All"
estadd local has_controls "Y"
estadd local has_issuer_fe "Y"
estadd local has_county_ym_fe "Y"
estadd local equal_weight "N"

eststo: reghdfe mma_spread_mvw_w  pct_std_post c.(log_med_pr_exp_yr log_med_pr_noexp_yr)#i.year $controls if  state != "CA"  &log_median_hp !=. & year > 2006, absorb(ym_date##fips dist_num  $intcontrols) vce(cluster fips ym_date)
	estadd scalar N_true = e(N) + e(num_singletons)
			estadd scalar within_r2 = e(r2_within)
sum mma_spread_mvw_w if e(sample) == 1
estadd scalar outcome_mean r(mean)
estadd scalar outcome_sd r(sd)
estadd local subsample "East \& Gulf"
	estadd local hp_measure "MHP by Exposure"
	estadd local worried "All"
estadd local has_controls "Y"
estadd local has_issuer_fe "Y"
estadd local has_county_ym_fe "Y"
estadd local equal_weight "N"

	eststo: reghdfe mma_spread_mvw_w  pct_std_post  c.(log_zillow_hp)#i.year $controls if  state != "CA" &log_median_hp !=. & year > 2006, absorb(ym_date##fips dist_num  $intcontrols) vce(cluster fips ym_date)
	estadd scalar N_true = e(N) + e(num_singletons)
	estadd scalar within_r2 = e(r2_within)
	sum mma_spread_mvw_w if e(sample) == 1
	estadd scalar outcome_mean r(mean)
	estadd scalar outcome_sd r(sd)
	estadd local subsample "East \& Gulf"
	estadd local hp_measure "Zillow HP"
	estadd local worried "All"
	estadd local has_controls "Y"
	estadd local has_issuer_fe "Y"
	estadd local has_county_ym_fe "Y"
	estadd local equal_weight "N"


	eststo: reghdfe mma_spread_mvw_w  pct_std_post c.(log_median_hp  log_p10_price log_p25_price log_p75_price log_p90_price)#i.year    $controls if  state != "CA" &log_median_hp !=. & year > 2006, absorb(ym_date##fips dist_num  $intcontrols) vce(cluster fips ym_date)
	estadd scalar N_true = e(N) + e(num_singletons)
	estadd scalar within_r2 = e(r2_within)
	sum mma_spread_mvw_w if e(sample) == 1
	estadd scalar outcome_mean r(mean)
	estadd scalar outcome_sd r(sd)
	estadd local subsample "East \& Gulf"
	estadd local hp_measure "HP Dist."
	estadd local worried "All"
	estadd local has_controls "Y"
	estadd local has_issuer_fe "Y"
	estadd local has_county_ym_fe "Y"
estadd local equal_weight "N"
}
esttab, compress nogaps b(3) keep( pct_std_post ) ///
stats(   has_controls has_county_ym_fe has_county_ym_fe  outcome_mean outcome_sd N_true r2 within_r2, fmt( %9.3fc %9.3fc %9.3fc %9.3fc %9.3fc %9.0fc %9.4f) ///
 labels(  "Controls" "District FE" "County-Year-Month FE" "Outcome Mean" "Outcome SD" "Observations" "R\$^2\$" "Within-R\$^2\$")) ///
  label interaction(" X ") starlevels(* 0.10 ** 0.05 *** 0.01) nomtitles 
esttab using "$tablePath/regs_house_price_table_w_year_2007.tex", booktabs replace compress nogaps b(3) keep(pct_std_post) ///
stats( hp_measure  has_controls has_county_ym_fe has_county_ym_fe   outcome_mean outcome_sd N_true r2 within_r2, fmt( %9.3fc %9.3fc %9.3fc %9.3fc  %9.3fc %9.3fc %9.0fc %9.4f %9.4f) ///
 labels("House Price Control Measure" "Controls" "District FE" "County-Year-Month FE"   "Outcome Mean" "Outcome SD" "Observations" "R\$^2\$" "Within-R\$^2\$")) ///
  label interaction(" $\times$ ") starlevels(* 0.10 ** 0.05 *** 0.01) nomtitles  nonotes



/** Table 6 ***/
/*** Time Variation in Forecasts -- Mean vs. Variance in SLR Forecasts **/
drop year_range_r-range_treat
capture drop _merge
merge m:1 year using "$dataPath/SLR Projections/SLRProjectionsseries_final_8_16.dta"


ren average_* *

ren year_range_r year_range_r2
ren year_range year_range2
ren year_range1 year_range
ren year_range_r1 year_range_r
ren year_high_r year_high_r2
ren year_high year_high2
ren year_high1 year_high
ren year_high_r1 year_high_r


capture drop _merge
merge m:1 year using "$dataPath/SLR Projections/scholar_study_ratio.dta"

foreach var1 of varlist ratio mean* year_range* year_high*  sd* {
		center `var1' if state!="CA", g(`var1'_std) standardize
}


label var mean_std "Mean Forecast"
label var mean2_std "Mean Forecast (All Risk, 2yr)"
label var sd_std "St. Dev. of Forecasts (All Risk)"
label var year_range_std "Range of Forecasts (All Risk)"
label var year_high_std "Worst Forecast"
label var sd_high_std  "St. Dev. of Forecasts (High Risk)"
label var sd_mid_std  "St. Dev. of Forecasts (Med Risk)"
label var mean_high_std  "Mean Forecasts (High Risk)"
label var mean_mid_std  "Mean Forecasts (Med Risk)"
label var pct_std "Frac Exposed"
label var sd2_std "St. Dev. of Forecasts (All Risk, 2yr)"
label var sd_high2_std "St. Dev. of Forecasts (High Risk, 2yr)"
label var year_high2_std "Worst Forecast (2yr)"
label var year_range2_std "Range of Forecasts (All Risk, 2yr)"
label var sd_high2_std  "St. Dev. of Forecasts (High Risk, 2yr)"
label var sd_mid2_std  "St. Dev. of Forecasts (Med Risk, 2yr)"
keep if year>=2007
est clear


eststo c1: reghdfe  mma_spread_mvw_w   c.pct_std#c.mean2_std  $controls if  state != "CA" , absorb(ym_date##fips dist_num $intcontrols) vce(cluster fips ym_date) noconstant

eststo c2: reghdfe  mma_spread_mvw_w   c.pct_std#c.sd2_std $controls if  state != "CA" , absorb(ym_date##fips dist_num $intcontrols) vce(cluster fips ym_date) noconstant

eststo c3: reghdfe  mma_spread_mvw_w    c.pct_std#c.year_range2_std $controls if  state != "CA" , absorb(ym_date##fips dist_num $intcontrols) vce(cluster fips ym_date) noconstant

eststo c4: reghdfe  mma_spread_mvw_w    c.pct_std#c.year_high2_std $controls if  state != "CA" , absorb(ym_date##fips dist_num $intcontrols) vce(cluster fips ym_date) noconstant

eststo c5: reghdfe  mma_spread_mvw_w    c.pct_std#c.sd_mid2_std $controls if  state != "CA" , absorb(ym_date##fips dist_num $intcontrols) vce(cluster fips ym_date) noconstant

eststo c6: reghdfe  mma_spread_mvw_w    c.pct_std#c.sd_high2_std $controls if  state != "CA" , absorb(ym_date##fips dist_num $intcontrols) vce(cluster fips ym_date) noconstant

scalar N_t = e(N) + e(num_singletons)
sum mma_spread_mvw_w if e(sample) == 1
scalar outcome_m= r(mean)
scalar outcome_s = r(sd)

eststo m_1: appendmodels c1 c2 c3 c4 c5 c6
estadd scalar N_true N_t
estadd scalar outcome_mean outcome_m
estadd scalar outcome_sd outcome_s
estadd local articles "All"
estadd local has_controls "Y"
estadd local has_issuer_fe "Y"
estadd local has_county_ym_fe "Y"



foreach var1 of varlist  sd2_std year_range2_std year_high2_std  {

quietly{



quietly eststo m_`var1': reghdfe  mma_spread_mvw_w   c.pct_std#c.`var1' c.pct_std#c.mean2_std $controls if  state != "CA" , absorb(ym_date##fips dist_num $intcontrols) vce(cluster fips ym_date) noconstant
estadd scalar N_true = e(N) + e(num_singletons)
sum mma_spread_mvw_w if e(sample) == 1
estadd scalar outcome_mean r(mean)
estadd scalar outcome_sd r(sd)
estadd local articles "All"
estadd local has_controls "Y"
estadd local has_issuer_fe "Y"
estadd local has_county_ym_fe "Y"
}
}

quietly eststo m_last: reghdfe  mma_spread_mvw_w  c.pct_std#c.mean2_std c.pct_std#c.sd_mid2_std c.pct_std#c.sd_high2_std $controls if  state != "CA" , absorb(ym_date##fips dist_num $intcontrols) vce(cluster fips ym_date) noconstant
estadd scalar N_true = e(N) + e(num_singletons)
sum mma_spread_mvw_w if e(sample) == 1
estadd scalar outcome_mean r(mean)
estadd scalar outcome_sd r(sd)
estadd local articles "All"
estadd local has_controls "Y"
estadd local has_issuer_fe "Y"
estadd local has_county_ym_fe "Y"


esttab m* using "${tablePath}/sd_v_mean2.tex", booktabs replace compress nogaps b(3) drop($controls ) varwidth(60) ///
 stats( articles has_controls  has_county_ym_fe has_issuer_fe outcome_mean outcome_sd N_true, fmt(  %9.3fc %9.3fc %9.3fc %9.3fc %9.3fc %9.3fc %9.0fc) ///
 labels( "Articles for Projection" "Controls" "County-Year-Month FE" "District FE"  "Outcome Mean" "Outcome SD" "Observations")) /// 
 label interaction(" X ") starlevels(* 0.10 ** 0.05 *** 0.01) nomtitles  nonotes mgroups("Univariate" "Bivariate", pattern(1 1 0 0 0) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span}))


esttab m*, compress nogaps b(3) drop($controls ) varwidth(60) ///
 stats( articles has_controls  has_county_ym_fe has_issuer_fe outcome_mean outcome_sd N_true, fmt(  %9.3fc %9.3fc %9.3fc %9.3fc %9.3fc %9.3fc %9.0fc) ///
 labels( "Articles for Projection" "Controls" "County-Year-Month FE" "District FE"  "Outcome Mean" "Outcome SD" "Observations")) /// 
 label interaction(" X ") starlevels(* 0.10 ** 0.05 *** 0.01) nomtitles  

 
 est clear
g yr=.
g yr_rl=.
g yr2=.
g yr_rl2=.
label var yr "1 Year, All Studies"
label var yr_rl "1 Year, Select Studies"
label var yr2 "2 Years, All Studies"
label var yr_rl2 "2 Years, Select Studies"
est clear
foreach var of varlist  sd year_range year_high   {
	quietly {


		replace yr=`var'_std
		replace yr_rl=`var'_r_std
		replace yr2=`var'2_std
		replace yr_rl2=`var'_r2_std


		eststo c3: reghdfe  mma_spread_mvw_w   c.pct_std#c.yr  $controls if  state != "CA" , absorb(ym_date##fips dist_num $intcontrols) vce(cluster fips ym_date) noconstant

		eststo c4: reghdfe  mma_spread_mvw_w   c.pct_std#c.yr_rl $controls if  state != "CA" , absorb(ym_date##fips dist_num $intcontrols) vce(cluster fips ym_date) noconstant

		eststo c1: reghdfe  mma_spread_mvw_w    c.pct_std#c.yr2 $controls if  state != "CA" , absorb(ym_date##fips dist_num $intcontrols) vce(cluster fips ym_date) noconstant

		eststo c2: reghdfe  mma_spread_mvw_w    c.pct_std#c.yr_rl2 $controls if  state != "CA" , absorb(ym_date##fips dist_num $intcontrols) vce(cluster fips ym_date) noconstant

		scalar N_t = e(N) + e(num_singletons)

		sum mma_spread_mvw_w if e(sample) == 1
		local outcome_m = r(mean)
		local outcome_s = r(sd)
		eststo m_`var': appendmodels c1 c2 c3 c4
		estadd scalar N_true N_t
		estadd scalar outcome_mean `outcome_m'
		estadd scalar outcome_sd `outcome_s'
		estadd local has_controls "Y"
		estadd local has_issuer_fe "Y"
		estadd local has_county_ym_fe "Y"

		}
}

esttab m_* using "${tablePath}/projections_robust.tex", nodepvar booktabs replace compress nogaps b(3) drop($controls ) varwidth(60) ///
 stats(  has_controls  has_county_ym_fe has_issuer_fe outcome_mean outcome_sd N_true, fmt(   %9.3fc %9.3fc %9.3fc  %9.3fc %9.3fc %9.0fc ) ///
 labels(  "Controls" "County-Year-Month FE" "District FE" "Outcome Mean" "Outcome SD" "Observations")) /// 
 label interaction(" X ") starlevels(* 0.10 ** 0.05 *** 0.01) mtitles("Std. Dev." "Range" "Highest Estimate")  nonotes nonumbers
 
 
 
esttab m_*, compress nogaps b(3) drop($controls ) varwidth(60) nodepvars mtitles("Std. Dev." "Range" "Highest Estimate") ///
 stats(  has_controls  has_county_ym_fe has_issuer_fe outcome_mean outcome_sd N_true, fmt(   %9.3fc %9.3fc %9.3fc  %9.3fc %9.3fc %9.0fc ) ///
 labels( "Controls" "County-Year-Month FE" "District FE"  )) /// 
 label interaction(" X ") starlevels(* 0.10 ** 0.05 *** 0.01)   
 
 
 

g ratio_mean=mean_mid*(1-ratio)+mean_high*ratio
center ratio_mean, standardize g(ratio_mean_std)

g ratio_mean2=mean_mid2*(1-ratio)+mean_high2*ratio
center ratio_mean2, standardize g(ratio_mean2_std)
g ratio_sd=sd_mid*(1-ratio)+sd_high*ratio
center ratio_sd, standardize g(ratio_sd_std)
g ratio_sd2=sd_high2*ratio+sd_mid2*(1-ratio)
center ratio_sd2, standardize g(ratio_sd2_std)
label var ratio_std "Ratio of 8.5 to 4.5 (Google Scholar)"
label var ratio_sd2_std "Attention Weighted St. Dev. (2yr)"
label var ratio_mean2_std "Attention Weighted Mean (2yr)"

est clear



eststo: reghdfe  mma_spread_mvw_w   c.pct_std#c.ratio_mean2_std  $controls if  state != "CA" , absorb(ym_date##fips dist_num $intcontrols) vce(cluster fips ym_date) noconstant
estadd scalar N_true = e(N) + e(num_singletons)
sum mma_spread_mvw_w if e(sample) == 1
estadd scalar outcome_mean r(mean)
estadd scalar outcome_sd r(sd)
estadd local has_controls "Y"
estadd local has_issuer_fe "Y"
estadd local has_county_ym_fe "Y"



eststo: reghdfe  mma_spread_mvw_w   c.pct_std#c.ratio_sd2_std  $controls if  state != "CA" , absorb(ym_date##fips dist_num $intcontrols) vce(cluster fips ym_date) noconstant
estadd scalar N_true = e(N) + e(num_singletons)
sum mma_spread_mvw_w if e(sample) == 1
estadd scalar outcome_mean r(mean)
estadd scalar outcome_sd r(sd)
estadd local has_controls "Y"
estadd local has_issuer_fe "Y"
estadd local has_county_ym_fe "Y"


eststo: reghdfe  mma_spread_mvw_w  c.pct_std#c.ratio_sd2_std  c.pct_std#c.ratio_mean2_std $controls if  state != "CA" , absorb(ym_date##fips dist_num $intcontrols) vce(cluster fips ym_date) noconstant
estadd scalar N_true = e(N) + e(num_singletons)
sum mma_spread_mvw_w if e(sample) == 1
estadd scalar outcome_mean r(mean)
estadd scalar outcome_sd r(sd)
estadd local has_controls "Y"
estadd local has_issuer_fe "Y"
estadd local has_county_ym_fe "Y"



esttab, compress nogaps b(3) drop($controls ) varwidth(60) ///
 stats(  has_controls  has_county_ym_fe has_issuer_fe outcome_mean outcome_sd N_true, fmt(   %9.3fc %9.3fc %9.3fc %9.3fc %9.3fc %9.0fc) ///
 labels(  "Controls" "County-Year-Month FE" "District FE"  "Outcome Mean" "Outcome SD" "Observations")) /// 
 label interaction(" X ") starlevels(* 0.10 ** 0.05 *** 0.01) nomtitles  nonotes



esttab using "${tablePath}/projections_vs_ratio.tex", booktabs replace compress nogaps b(3) drop($controls ) varwidth(60) ///
 stats(  has_controls  has_county_ym_fe has_issuer_fe outcome_mean outcome_sd N_true, fmt(   %9.3fc %9.3fc %9.3fc %9.3fc %9.3fc %9.0fc) ///
 labels(  "Controls" "County-Year-Month FE" "District FE"  "Outcome Mean" "Outcome SD" "Observations")) /// 
 label interaction(" X ") starlevels(* 0.10 ** 0.05 *** 0.01) nomtitles  nonotes





quietly{
est clear


eststo: reghdfe  mma_spread_mvw_w   c.pct_std#c.ratio_weighted_std  $controls if  state != "CA" , absorb(ym_date##fips dist_num $intcontrols) vce(cluster fips ym_date) noconstant
estadd scalar N_true = e(N) + e(num_singletons)
sum mma_spread_mvw_w if e(sample) == 1
estadd scalar outcome_mean r(mean)
estadd scalar outcome_sd r(sd)
estadd local has_controls "Y"
estadd local has_issuer_fe "Y"
estadd local has_county_ym_fe "Y"



eststo: reghdfe  mma_spread_mvw_w   c.pct_std#c.ratio_weighted_2_std c.pct_std#c.sd2_std $controls if  state != "CA" , absorb(ym_date##fips dist_num $intcontrols) vce(cluster fips ym_date) noconstant
estadd scalar N_true = e(N) + e(num_singletons)
sum mma_spread_mvw_w if e(sample) == 1
estadd scalar outcome_mean r(mean)
estadd scalar outcome_sd r(sd)
estadd local has_controls "Y"
estadd local has_issuer_fe "Y"
estadd local has_county_ym_fe "Y"

eststo: reghdfe  mma_spread_mvw_w   c.pct_std#c.ratio_weighted_std c.pct_std#c.year_range2_std $controls if  state != "CA" , absorb(ym_date##fips dist_num $intcontrols) vce(cluster fips ym_date) noconstant
estadd scalar N_true = e(N) + e(num_singletons)
sum mma_spread_mvw_w if e(sample) == 1
estadd scalar outcome_mean r(mean)
estadd scalar outcome_sd r(sd)
estadd local has_controls "Y"
estadd local has_issuer_fe "Y"
estadd local has_county_ym_fe "Y"


eststo: reghdfe  mma_spread_mvw_w   c.pct_std#c.ratio_weighted_std c.pct_std#c.year_high2_std  $controls if  state != "CA" , absorb(ym_date##fips dist_num $intcontrols) vce(cluster fips ym_date) noconstant
estadd scalar N_true = e(N) + e(num_singletons)
sum mma_spread_mvw_w if e(sample) == 1
estadd scalar outcome_mean r(mean)
estadd scalar outcome_sd r(sd)
estadd local has_controls "Y"
estadd local has_issuer_fe "Y"
estadd local has_county_ym_fe "Y"


eststo : reghdfe  mma_spread_mvw_w  c.pct_std#c.ratio_weighted_std c.pct_std#c.sd_high2_std  $controls if  state != "CA" , absorb(ym_date##fips dist_num $intcontrols) vce(cluster fips ym_date) noconstant
estadd scalar N_true = e(N) + e(num_singletons)
sum mma_spread_mvw_w if e(sample) == 1
estadd scalar outcome_mean r(mean)
estadd scalar outcome_sd r(sd)
estadd local has_controls "Y"
estadd local has_issuer_fe "Y"
estadd local has_county_ym_fe "Y"

}
esttab, compress nogaps b(3) drop($controls ) varwidth(60) ///
 stats(  has_controls  has_county_ym_fe has_issuer_fe outcome_mean outcome_sd N_true, fmt(   %9.3fc %9.3fc %9.3fc %9.3fc %9.3fc %9.0fc) ///
 labels(  "Controls" "County-Year-Month FE" "District FE"  "Outcome Mean" "Outcome SD" "Observations")) /// 
 label interaction(" X ") starlevels(* 0.10 ** 0.05 *** 0.01) nomtitles  nonotes



esttab using "${tablePath}/projections_vs_ratio2yr.tex", booktabs replace compress nogaps b(3) drop($controls ) varwidth(60) ///
 stats(  has_controls  has_county_ym_fe has_issuer_fe outcome_mean outcome_sd N_true, fmt(   %9.3fc %9.3fc %9.3fc %9.3fc %9.3fc %9.0fc) ///
 labels(  "Controls" "County-Year-Month FE" "District FE"  "Outcome Mean" "Outcome SD" "Observations")) /// 
 label interaction(" X ") starlevels(* 0.10 ** 0.05 *** 0.01) nomtitles  nonotes

 
 

/*** Table 7 ****/
/**** WORRIED TABLE ***/
gen pct_std_post_worried = pct_std_post*ave_state_worried_2014
label var  pct_std_post_worried "SLR Exposure \$\times\$ 1(Post) \$\times\$ State Worry"
quietly{
est clear

eststo: reghdfe mma_spread_mvw_w pct_std_post   $controls if worry == 1 & state != "CA", absorb(ym_date##fips dist_num  $intcontrols) vce(cluster fips ym_date)
estadd scalar N_true = e(N) + e(num_singletons)
estadd scalar within_r2 = e(r2_within)	
sum mma_spread_mvw_w if e(sample) == 1
estadd scalar outcome_mean r(mean)
estadd scalar outcome_sd r(sd)
estadd local subsample "East \& Gulf"
estadd local worried "Worried"
estadd local has_controls "Y"
estadd local has_issuer_fe "Y"
estadd local has_county_ym_fe "Y"
estadd local equal_weight "N"

*ib2001.year##c.(pct_std )

eststo: reghdfe mma_spread_mvw_w pct_std_post  $controls if worry == 0 & state != "CA", absorb(ym_date##fips dist_num  $intcontrols) vce(cluster fips ym_date)
estadd scalar N_true = e(N) + e(num_singletons)
estadd scalar within_r2 = e(r2_within)	
sum mma_spread_mvw_w if e(sample) == 1
estadd scalar outcome_mean r(mean)
estadd scalar outcome_sd r(sd)
estadd local subsample "East \& Gulf"
estadd local worried "Not Worried"
estadd local has_controls "Y"
estadd local has_issuer_fe "Y"
estadd local has_county_ym_fe "Y"
estadd local equal_weight "N"

eststo: reghdfe mma_spread_mvw_w  pct_std_post pct_std_post_worried $controls if state != "CA", absorb(ym_date##fips dist_num  $intcontrols) vce(cluster fips ym_date)
estadd scalar N_true = e(N) + e(num_singletons)
estadd scalar within_r2 = e(r2_within)	
sum mma_spread_mvw_w if e(sample) == 1
estadd scalar outcome_mean r(mean)
estadd scalar outcome_sd r(sd)
estadd local subsample "East \& Gulf"
estadd local worried "All"
estadd local has_controls "Y"
estadd local has_issuer_fe "Y"
estadd local has_county_ym_fe "Y"
estadd local equal_weight "N"
}

esttab, compress nogaps b(3) keep(pct_std_post pct_std_post_worried) ///
 stats(subsample worried has_controls has_issuer_fe has_county_ym_fe outcome_mean outcome_sd N_true r2 within_r2, fmt(%9.3fc %9.3fc %9.3fc %9.3fc %9.3fc %9.3fc %9.3fc %9.0fc %9.4f %9.4f) ///
 labels("Sample" "Level of Concern" "Controls" "District FE" "County-Year-Month FE" "Outcome Mean" "Outcome SD" "Observations" "R\$^2\$" "Within-R\$^2\$")) varwidth(50) ///
 label interaction(" X ") starlevels(* 0.10 ** 0.05 *** 0.01) nomtitles 
esttab using "$tablePath/regs_worried_${isbal}_`feet'.tex", booktabs replace compress nogaps b(3) keep( pct_std_post pct_std_post_worried) ///
 stats( worried has_controls has_issuer_fe has_county_ym_fe outcome_mean outcome_sd N_true r2 within_r2, fmt( %9.3fc %9.3fc %9.3fc %9.3fc %9.3fc %9.3fc %9.0fc %9.4f %9.4f) ///
 labels("Level of Concern" "Controls" "District FE" "County-Year-Month FE" "Outcome Mean" "Outcome SD" "Observations" "R\$^2\$" "Within-R\$^2\$")) ///
 label interaction(" $\times$ ") starlevels(* 0.10 ** 0.05 *** 0.01) nomtitles  nonotes



/*** Table 8 ****/
/*** TAX TABLE ***/
* property tax mechanism

label var rate_std "Property Tax Rate (Std)"
label var local_std "School Local Funding Pct (Std)"
gen rate_std_post = rate_std * post
gen pct_std_rate_std_post = pct_std* rate_std * post
gen pct_std_local_std_post = pct_std* local_std * post
label var pct_std_rate_std_post "SLR Exposure \$\times\$ 1(Post) \$\times\$ Property Tax Rate"
label var pct_std_local_std_post "SLR Exposure \$\times\$ 1(Post) \$\times\$ School Local Funding"
quietly{
est clear

eststo: reghdfe mma_spread_mvw_w pct_std_post rate_std_post pct_std_rate_std_post $controls if  state != "CA", absorb(ym_date##fips dist_num  $intcontrols) vce(cluster fips ym_date)
estadd scalar N_true = e(N) + e(num_singletons)
estadd scalar within_r2 = e(r2_within)	
sum mma_spread_mvw_w if e(sample) == 1
estadd scalar outcome_mean r(mean)
estadd scalar outcome_sd r(sd)
estadd local subsample "Main"
estadd local has_controls "Y"
estadd local has_issuer_fe "Y"
estadd local has_county_ym_fe "Y"
estadd local equal_weight "N"


eststo: reghdfe mma_spread_mvw_w pct_std_post pct_std_local_std_post $controls if  state != "CA", absorb(ym_date##fips dist_num  $intcontrols) vce(cluster fips ym_date)
estadd scalar N_true = e(N) + e(num_singletons)
estadd scalar within_r2 = e(r2_within)	
sum mma_spread_mvw_w if e(sample) == 1
estadd scalar outcome_mean r(mean)
estadd scalar outcome_sd r(sd)
estadd local subsample "Main"
estadd local has_controls "Y"
estadd local has_issuer_fe "Y"
estadd local has_county_ym_fe "Y"
estadd local equal_weight "N"


eststo: reghdfe mma_spread_mvw_w pct_std_post $controls if state=="CA", absorb(ym_date##fips dist_num  $intcontrols) vce(cluster fips ym_date)
estadd scalar N_true = e(N) + e(num_singletons)
estadd scalar within_r2 = e(r2_within)	
sum mma_spread_mvw_w if e(sample) == 1
estadd scalar outcome_mean r(mean)
estadd scalar outcome_sd r(sd)
estadd local subsample "CA"
estadd local has_controls "Y"
estadd local has_issuer_fe "Y"
estadd local has_county_ym_fe "Y"
estadd local equal_weight "N"


}

esttab, compress nogaps b(3) keep(pct_std_post pct_std_rate_std_post  pct_std_local_std_post   ) ///
 stats(subsample  has_controls has_issuer_fe has_county_ym_fe outcome_mean outcome_sd N_true r2 within_r2, fmt(%9.3fc %9.3fc %9.3fc %9.3fc %9.3fc %9.3fc %9.0fc %9.4f %9.4f) ///
 labels("Sample" "Controls" "District FE" "County-Year-Month FE" "Outcome Mean" "Outcome SD" "Observations" "R\$^2\$" "Within-R\$^2\$")) varwidth(50) ///
 label interaction(" X ") starlevels(* 0.10 ** 0.05 *** 0.01) nomtitles 
esttab using "$tablePath/regs_tax_${isbal}_`feet'.tex", booktabs replace compress nogaps b(3) keep(pct_std_post pct_std_rate_std_post  pct_std_local_std_post   ) ///
 stats(subsample has_controls has_issuer_fe has_county_ym_fe outcome_mean outcome_sd N_true r2 within_r2, fmt(%9.3fc %9.3fc %9.3fc %9.3fc %9.3fc %9.3fc %9.0fc %9.4f %9.4f) ///
 labels("Sample" "Controls" "District FE" "County-Year-Month FE" "Outcome Mean" "Outcome SD" "Observations" "R\$^2\$" "Within-R\$^2\$")) ///
 label interaction(" $\times$ ") starlevels(* 0.10 ** 0.05 *** 0.01) nomtitles  nonotes


/*** Table 9 ****/
* distress policy interactions table
gen distress_proactive = (state == "ME" | state == "NC" | state == "NJ" | state == "NY")
label var distress_proactive "1(Proactive)"

gen distress_chap9 = (state == "SC" | state == "TX" | state == "CA")
label var distress_chap9 "1(Chapter 9)"

gen distress_neither = (state == "CT" | state == "LA" | state == "MA" | state == "MS" | state == "RI")

gen pct_std_post_proactive = pct_std_post*distress_proactive
gen pct_std_post_chap9 = pct_std_post*distress_chap9
label var pct_std_post_proactive "SLR Exposure \$\times\$ 1(Post) \$\times\$ 1(Proactive)"
label var pct_std_post_chap9 "SLR Exposure \$\times\$ 1(Post) \$\times\$ 1(Chapter 9)"

quietly{
est clear

eststo: reghdfe mma_spread_mvw_w pct_std_post $controls if distress_proactive == 1 & state != "CA", absorb(ym_date##fips dist_num $intcontrols) vce(cluster fips ym_date)
estadd scalar N_true = e(N) + e(num_singletons)
estadd scalar within_r2 = e(r2_within)	
sum mma_spread_mvw_w if e(sample) == 1
estadd scalar outcome_mean r(mean)
estadd scalar outcome_sd r(sd)
estadd local distress "Proactive"
estadd local has_controls "Y"
estadd local has_issuer_fe "Y"
estadd local has_county_ym_fe "Y"
estadd local equal_weight "N"

eststo: reghdfe mma_spread_mvw_w pct_std_post  $controls if distress_chap9 == 1 & state != "CA", absorb(ym_date##fips dist_num $intcontrols) vce(cluster fips ym_date)
estadd scalar N_true = e(N) + e(num_singletons)
estadd scalar within_r2 = e(r2_within)	
sum mma_spread_mvw_w if e(sample) == 1
estadd scalar outcome_mean r(mean)
estadd scalar outcome_sd r(sd)
estadd local distress "Chapter 9"
estadd local has_controls "Y"
estadd local has_issuer_fe "Y"
estadd local has_county_ym_fe "Y"
estadd local equal_weight "N"

eststo: reghdfe mma_spread_mvw_w pct_std_post $controls if distress_neither == 1 & state != "CA", absorb(ym_date##fips dist_num $intcontrols) vce(cluster fips ym_date)
estadd scalar N_true = e(N) + e(num_singletons)
estadd scalar within_r2 = e(r2_within)	
sum mma_spread_mvw_w if e(sample) == 1
estadd scalar outcome_mean r(mean)
estadd scalar outcome_sd r(sd)
estadd local distress "Neither"
estadd local has_controls "Y"
estadd local has_issuer_fe "Y"
estadd local has_county_ym_fe "Y"
estadd local equal_weight "N"

eststo: reghdfe mma_spread_mvw_w pct_std_post pct_std_post_proactive $controls if state != "CA", absorb(ym_date##fips dist_num $intcontrols) vce(cluster fips ym_date)
estadd scalar N_true = e(N) + e(num_singletons)
estadd scalar within_r2 = e(r2_within)	
sum mma_spread_mvw_w if e(sample) == 1
estadd scalar outcome_mean r(mean)
estadd scalar outcome_sd r(sd)
estadd local distress "All"
estadd local has_controls "Y"
estadd local has_issuer_fe "Y"
estadd local has_county_ym_fe "Y"
estadd local equal_weight "N"
}
esttab, compress nogaps b(3) keep(pct_std_post pct_std_post_proactive) ///
stats(distress has_controls has_issuer_fe has_county_ym_fe outcome_mean outcome_sd N_true r2 within_r2, fmt(%9.3fc %9.3fc %9.3fc %9.3fc %9.3fc %9.3fc %9.0fc %9.4f %9.4f) ///
labels("Distress Policy" "Controls" "District FE" "County-Year-Month FE" "Outcome Mean" "Outcome SD" "Observations" "R\$^2\$" "Within-R\$^2\$")) varwidth(50) ///
label interaction(" X ") starlevels(* 0.10 ** 0.05 *** 0.01) nomtitles
esttab using "$tablePath/regs_distress.tex", booktabs replace compress nogaps b(3) keep(pct_std_post pct_std_post_proactive) ///
stats(distress has_controls has_issuer_fe has_county_ym_fe outcome_mean outcome_sd N_true r2 within_r2, fmt(%9.3fc %9.3fc %9.3fc %9.3fc %9.3fc %9.3fc %9.0fc %9.4f %9.4f) ///
labels("Distress Policy" "Controls" "District FE" "County-Year-Month FE" "Outcome Mean" "Outcome SD" "Observations" "R\$^2\$" "Within-R\$^2\$")) varwidth(50) ///
label interaction(" X ") starlevels(* 0.10 ** 0.05 *** 0.01) nomtitles nonotes
